import java.util.Arrays;
public class test {
    public static void main(String[] args) {
        int[] arr = {1,3,7,1,3,2,17,85,35,16};
/*        //System.out.println(Arrays.toString(arr));
        System.out.println(myTOString(arr));
        BubbleSort(arr);
//        Arrays.sort(arr);
        System.out.println(myTOString(arr));
//        Arrays.sort(arr,0,5);
//        System.out.println(Arrays.toString(arr));*/
        System.out.println(Arrays.toString(arr));
        reverse(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void reverse(int[] arr) {
        if(arr==null) return;
        int left = 0;
        int right = arr.length-1;
        while(left<right) {
            int tem = arr[left];
            arr[left] = arr[right];
            arr[right] = tem;
            left++;
            right--;
        }
    }
    public static void BubbleSort(int[] arr) {
        for (int i = 0; i < arr.length-1; i++) {
            boolean k = false;
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j]>arr[j+1]) {
                    int tem = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tem;
                    k = true;
                }
            }
            if(!k) {
                return;
            }
        }
    }
    public static String myTOString(int[] arr) {
        if(arr==null) {
            System.out.println("null");
        }
        if(arr.length==0) {
            System.out.println("[]");
        }
        String ret = "[";
        for (int i = 0; i < arr.length; i++) {
            if(i != arr.length - 1)
            ret += arr[i]+", ";
            else
                ret += arr[i]+"]";
        }
        return ret;
    }
    public static void mainm5(String[] args) {
        int[] arr = {1,2,3};
        arr = revise2(arr);
        for (int x: arr) {
            System.out.println(x);
        }
    }
    public static int[] revise2(int[] arr) {
        arr = new int[] {4,5,6};
        return arr;
    }
    public static void revise1(int[] arr) {
        arr[0] = 100;
    }
    public static void main4(String[] args) {
        int[] arr = null;
        System.out.println(arr.length);
    }
    public static void main3(String[] args) {
        int[] arr1 = {1,2,3};
        int[] arr2 = {100};
        arr2 = arr1;
        for (int x:arr2) {
            System.out.println(x);
        }
    }
    public static void main2(String[] args) {
/*        int[] arr1;
        arr1 = new int[10];
        *//*int[] arr2;
        arr2 = new int[]{1,2,3};
        System.out.println(arr1);
        System.out.println(arr2);*//*
        int[] arr2 = {1,2,3};*/
        int[] arr = {1,2,3};
/*        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);*/
        arr[0] = 100;
        //System.out.println(arr[0]);
/*        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }*/
        for (int x:arr) {
            x = 1;
        }
        for (int x: arr) {
            System.out.println(x);
        }
    }
    public static void main1(String[] args) {
        int[] arr = new int[10];
        int[] arr1 = {1,2,3};
        int[] arr2 = new int[]{1,2,3};
    }
}
